<?php
/*
 * Classe de view para XML 
 * 
 * Created on 20/08/2009
 *
 * @author Hugo L. S. Guimarães
 * @licence MIT 
 */ 

class XmlView extends View { 
	
    function render($action = null, $layout = null, $file = null) { 
        
       $out = "<".chr(63)."xml version=".chr(34)."1.0".chr(34)." encoding=".chr(34)."iso-8859-1".chr(34).chr(63).">".chr(13);
       $out .='<retorno_xml>'.chr(13);

	    while (list($key, $var) = each($this->viewVars)) { 
		    if (is_string($var)){ 
				$out .= "<$key>$var</$key>".chr(13);
				
		    }else{ 	
				$out .= "<$key>".chr(13);
			    while (list($key1, $val) = each($var)) {
				    if (is_array($val)){ 
					    
					    while (list($key2, $val2) = each($val)) {
						    if (is_array($val2)){ 
							    $out .= "<$key2 ";
							    
							    while (list($key3, $val3) = each($val2)) {
							    	$out .= $key3.'="'.$val3.'" ';
								   // $out .= "$key3='$val3' ";
							    }
							    
							    $out .= "/>".chr(13);
							    
						    } else {
							    $out .= "<$key2>$val2</$key2>".chr(13);
						    }   
					    }
					    
				    } else {
					    $out .= "<$key1>$val</$key1>".chr(13);
				    }   			
			    }
			    $out .= "</$key>".chr(13);
		    }
			
		}
		$out .='</retorno_xml>';
        return $out; 
    }
     
} 
?>
